package com.education.wisdom.service.impl;


import com.education.common.utils.Convert;
import com.education.common.utils.UUIDUtils;
import com.education.wisdom.mapper.ResourcesMapper;
import com.education.wisdom.pojo.Resources;
import com.education.wisdom.service.IResourcesService;
import com.education.wisdom.vo.ResourcesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 视频资源 服务层实现
 *
 * @author ruoyi
 * @date 2018-11-07
 */
@Service
public class ResourcesServiceImpl implements IResourcesService {
    @Autowired
    private ResourcesMapper resourcesMapper;

    @Override
    public List<Resources> selectByIds(String[] ids) {
        return resourcesMapper.selectByIds(ids);
    }

    @Override
    public List<Resources> selectResourcesByCatalogIdAndType(Integer catalogId, Integer type) {
        return resourcesMapper.selectResourcesByCatalogIdAndType(catalogId, type);
    }

    /**
     * 查询视频资源信息
     *
     * @param rCatalogid 所属课程信息
     * @return 视频资源信息
     */
    @Override
    public Resources selectUrl(Integer rCatalogid) {
        return resourcesMapper.selectUrl(rCatalogid);
    }

    @Override
    public ResourcesVo selectResources(Integer rCatalogid) {
        return resourcesMapper.selectResources(rCatalogid);
    }

    /**
     * 查询资源素材
     *
     * @param map
     * @return
     */
    @Override
    public List<Resources> selectInfoByType(Map<String, Object> map) {
        return resourcesMapper.selectInfoByType(map);
    }

    /**
     * 查询3D，flash资源
     *
     * @param map
     * @return
     */
    @Override
    public List<Resources> selectVideoById(Map<String, Object> map) {
        return resourcesMapper.selectVideoById(map);
    }

    @Override
    public Resources selectResourcesById(String resourceId) {
        return resourcesMapper.selectResourcesById(resourceId);
    }

    /**
     * 查询视频资源列表
     *
     * @param resources 视频资源信息
     * @return 视频资源集合
     */
    @Override
    public List<Resources> selectResourcesList(Resources resources) {
        return resourcesMapper.selectResourcesList(resources);
    }

    @Override
    public List<Resources> selectResourcesListBytype(Resources resources) {
        return resourcesMapper.selectResourcesListBytype(resources);
    }

    @Override
    public List<ResourcesVo> selectResourcesVoList(String userId) {
        return resourcesMapper.selectResourcesVoList(userId);
    }

    @Override
    public List<ResourcesVo> selectResourcesVoLists() {
        return resourcesMapper.selectResourcesVoLists();
    }

    /**
     * 新增视频资源
     *
     * @param resources 视频资源信息
     * @return 结果
     */
//	@Override
//	public int insertResources(Resources resources)
//	{
//	    return resourcesMapper.insertResources(resources);
//	}
    @Override
    public int insertResources(Resources resources) {
        resources.setrNumber(UUIDUtils.getByUUId());
        resources.setCreateTime(new Date());
        return resourcesMapper.insertResources(resources);
    }

    /**
     * 删除视频资源信息
     *
     * @param id 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteResourcesById(String id) {
        return resourcesMapper.deleteResourcesById(id);
    }

    /**
     * 修改视频资源
     *
     * @param resources 视频资源信息
     * @return 结果
     */
    @Override
    public int updateResources(Resources resources) {
        return resourcesMapper.updateResources(resources);
    }

    /**
     * 删除视频资源对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteResourcesByIds(String ids) {
        return resourcesMapper.deleteResourcesByIds(Convert.toStrArray(ids));
    }


    @Override
    public int deleteResourcesById2(String id) {
        return resourcesMapper.deleteResourcesById2(id);
    }


}
